<div id="flashMessageContainer">
    <div id="flashMessage" class="<?= $class ?>">
        <span class="message"><?= $message ?></span>
    </div>
</div>
<script type="text/javascript">
setTimeout(function(){
    $('#flashMessage').animate({
        top: -1*$(this).outerHeight()
    }, {
        duration: 300,
        complete: function(){
            $(this).hide();
            $('#flashMessageContainer').hide();
        }
    });
}, 4000);
</script>